﻿package 
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import idv.etrex.display.FlashGraphics;
	import idv.etrex.display.GraphicsBat;
	import idv.etrex.display.XGraphics;
	import idv.etrex.display.SVG;
	import idv.etrex.display.XGraphicsExecutor;
	/**
	 * ...
	 * @author etrex
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			//three type of igraphics
			var graphicsBat:GraphicsBat = new GraphicsBat();
			var xgraphics:XGraphics = new XGraphics();
			var svg:SVG = new SVG(550,400);
			
			//add to graphicsBat
			graphicsBat.add(new FlashGraphics(this.graphics));
			graphicsBat.add(xgraphics);
			graphicsBat.add(svg);
			
			//execute graphics command
			graphicsBat.lineStyle(2, 0);
			graphicsBat.beginFill(0xFFCCFF);
			graphicsBat.moveTo(10, 10);
			graphicsBat.lineTo(40, 90);
			graphicsBat.drawCircle(75, 25, 15);
			graphicsBat.drawEllipse(125, 25, 20, 10);
			graphicsBat.drawRect(60, 60, 30, 30);
			graphicsBat.drawRoundRect(110, 60, 30, 30, 10);
			graphicsBat.endFill();
			
			//reexecute graphics command
			var s:Shape = new Shape();
			s.y = 100;
			this.addChild(s);
			
			var graphicsBat2:GraphicsBat = new GraphicsBat();
			var svg2:SVG = new SVG(200,150);
			graphicsBat2.add(new FlashGraphics(s.graphics));
			graphicsBat2.add(svg2);
			
			var xge:XGraphicsExecutor = new XGraphicsExecutor(graphicsBat2, xgraphics);
			xge.executeAll();
			
			trace(svg.xml);
			trace(svg2.xml);
			trace(xgraphics.xml);
			
			//   output
			
			//<svg width="550" height="400" viewBox="0 0 550 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
			  //<line x1="10" y1="10" x2="40" y2="90" stroke-width="2" stroke="rgb(0,0,0)"/>
			  //<circle cx="75" cy="25" r="15" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<ellipse cx="125" cy="25" rx="20" ry="10" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<rect x="60" y="60" width="30" height="30" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<rect x="110" y="60" width="30" height="30" rx="10" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			//</svg>
			
			//<svg width="200" height="150" viewBox="0 0 200 150" xmlns="http://www.w3.org/2000/svg" version="1.1">
			  //<line x1="10" y1="10" x2="40" y2="90" stroke-width="2" stroke="rgb(0,0,0)"/>
			  //<circle cx="75" cy="25" r="15" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<ellipse cx="125" cy="25" rx="20" ry="10" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<rect x="60" y="60" width="30" height="30" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			  //<rect x="110" y="60" width="30" height="30" rx="10" fill="rgb(255,204,255)" stroke="rgb(0,0,0)" stroke-width="2"/>
			//</svg>
			
			//<XGraphics>
			  //<lineStyle thickness="2" color="0" alpha="1" pixelHinting="false" scaleMode="normal" caps="null" joints="null" miterLimit="3"/>
			  //<beginFill color="16764159" alpha="1"/>
			  //<moveTo x="10" y="10"/>
			  //<lineTo x="40" y="90"/>
			  //<drawCircle x="75" y="25" radius="15"/>
			  //<drawEllipse x="125" y="25" width="20" height="10"/>
			  //<drawRect x="60" y="60" width="30" height="30"/>
			  //<drawRoundRect x="110" y="60" width="30" height="30" ellipseWidth="10" ellipseHeight="NaN"/>
			  //<endFill/>
			//</XGraphics>
		}
	}
}